package edu.pku.sei.transformation.editor.controller.editparts.node;

import org.eclipse.draw2d.IFigure;
import org.eclipse.gef.EditPolicy;

import edu.pku.sei.modeler.model.structure.MetaShapeElement;
import edu.pku.sei.transformation.editor.controller.policies.CommonXYLayoutPolicy;
import edu.pku.sei.transformation.editor.controller.policies.NodeComponentEditPolicy;
import edu.pku.sei.transformation.editor.controller.policies.TransformationNodeEditPolicy;
import edu.pku.sei.transformation.editor.model.CompositeTransformation;
import edu.pku.sei.transformation.editor.model.Transformation;
import edu.pku.sei.transformation.editor.views.figures.CompositeTransformationFigure;
import edu.pku.sei.transformation.editor.views.figures.TransformationFigure;

public class CompositeTransformationEditpart extends TransformationEditpart {

	public CompositeTransformationEditpart(MetaShapeElement model) {
		super(model);
	}

	@Override
	protected IFigure createFigure() {
		TransformationFigure figure = new CompositeTransformationFigure();
		Transformation trans = (Transformation) getNode().getModelElement();
		figure.setName(trans.getName());
		figure.setTag("<<Composite Transformation>>");
		return figure;
	}
	
	@Override
	protected void createEditPolicies() {
		super.createEditPolicies();
		installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE,
				new TransformationNodeEditPolicy());
		installEditPolicy(EditPolicy.COMPONENT_ROLE,
				new NodeComponentEditPolicy());
		installEditPolicy(EditPolicy.LAYOUT_ROLE, new CommonXYLayoutPolicy());
	}
	
	@Override
	public IFigure getContentPane() {
		return ((CompositeTransformationFigure)getFigure()).getBody();
	}

}
